package com.taxshare.seller.controller;

import com.taxshare.response.beans.Response;
import com.taxshare.mybatis.pager.PageRequest;
import com.taxshare.seller.service.InvoicedService;
import com.taxshare.seller.service.RedTicketService;
import com.taxshare.seller.view.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javafx.scene.control.Pagination;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/redTicket")
@Api(tags="红字申请单")
public class RedTicketController {
    @Autowired
    private RedTicketService redTicketService;

    @Autowired
    private InvoicedService invoicedService;

    @ApiOperation(value = "查询红字申请单", notes = "查询红字申请单")
    @PostMapping("/queryTickets")
    public Response queryTickets(@RequestBody PageRequest<RedTicketReqVO> reqVo) {
        return redTicketService.queryTickets(reqVo);
    }

    @ApiOperation(value = "申请红字申请单", notes = "申请红字申请单，需调税神通接口")
    @PostMapping("/applyTicket")
    public Response applyTicket(@RequestBody TicketReqVO reqVo) throws Exception{
        return  redTicketService.applyTicket(reqVo);
    }

    @ApiOperation(value = "同步红字申请单", notes = "根据申请日期范围同步红字申请单，pagination参数不需要，需调税神通接口")
    @PostMapping("/syncTickets")
    public Response syncTickets(@RequestBody SyncRedTicketReqVO syncRedTicketReqVO) throws Exception {
        return redTicketService.syncTickets(syncRedTicketReqVO);
    }

    @ApiOperation(value = "撤销红字申请单", notes = "根据主键id撤销红字申请单")
    @PostMapping("/disableTicket")
    public Response disableTicket(@RequestBody RedTicketOperateReqVO reqVo) {
        return redTicketService.disableTicket(reqVo);
    }

    @ApiOperation(value = "生成红字预制发票", notes = "生成红字预制发票")
    @PostMapping("/produceRedPrecastInvoices")
    public Response produceRedPrecastInvoices(@RequestBody RedTicketOperateReqVO reqVo) {
        return redTicketService.produceRedPrecastInvoices(reqVo);
    }

    @PostMapping("/downloadRedInvoiceInfo")
    @ApiOperation(value = "下载红字信息表", notes = "红字信息表")
    public Response downloadRedInvoiceInfo(@RequestBody DownloadRedInvoiceVO vo) {
        return invoicedService.downloadRedInvoiceInfo(vo);
    }
}
